package io.renren.wechat.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.wechat.vo.FriendVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.wechat.entity.UsersEntity;
import io.renren.wechat.service.UsersService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;




/**
 * 
 *
 * @author hjy
 * @email 不告诉你
 * @date 2021-06-02 21:05:28
 */
@Api(tags = "users")
@RestController
@RequestMapping("wechat/users")
public class UsersController {
    @Autowired
    private UsersService usersService;




    /**
     * 列表
     */
    @ApiOperation(value = "基础列表查询")
    @ApiImplicitParam(name = "params",value = "聚合查询参数",required = false)
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = usersService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation(value = "基础id详情")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		UsersEntity users = usersService.getById(id);

        return R.ok().put("users", users);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "基础保存")
    @PostMapping("/save")
    public R save(@RequestBody UsersEntity users){
		usersService.save(users);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "基础修改")
    @PostMapping("/update")
    public R update(@RequestBody UsersEntity users){
		usersService.updateById(users);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "基础删除")
    @PostMapping("/delete")
    public R delete(@RequestBody String[] ids){
		usersService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
